package ${package}.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.goldgov.kcloud.core.json.JsonObject;
import com.goldgov.kcloud.core.json.JsonSuccessObject;

import ${package}.service.${module};
import ${package}.service.${module}Service;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/")
@Api("${module}服务接口")
public class ${module}Controller {
	
	@Autowired
	private ${module}Service service;
	
	@PostMapping
	@ApiOperation(value = "${module}保存", notes ="${module}描述")
	public JsonObject<Object> add${module}(${module} obj){
		//TODO 完善代码实现
		service.add${module}(obj);
		return JsonSuccessObject.SUCCESS;
	}
	
	@DeleteMapping
	@ApiOperation(value = "${module}删除", notes ="${module}描述")
	public JsonObject<Object> delete${module}(@ApiParam(value = "${module}ID", required = true) @RequestParam("ids") String[] ids){
		//TODO 完善代码实现
		service.delete${module}(ids);
		return JsonSuccessObject.SUCCESS;
	}
	
	@PutMapping
	@ApiOperation(value = "${module}修改", notes ="${module}描述")
	public JsonObject<Object> update${module}(${module} obj) {
		//TODO 完善代码实现
		service.update${module}(obj);
		return JsonSuccessObject.SUCCESS;
	}
	
	@GetMapping("/{id}")
	@ApiOperation(value = "根据主键查询${module}", notes ="${module}描述")
	public JsonSuccessObject<${module}> get${module}(@ApiParam(value="${module}ID",required=false) @PathVariable("id") String id){
		//TODO 完善代码实现
		${module} obj = service.get${module}(id);
		JsonSuccessObject<${module}> returnResult = new JsonSuccessObject<>(obj);
		return returnResult;
	}
	
}